<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>添加客户</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/css/font-awesome.css">
</head>

<body>
    <jsp:include page="/WEB-INF/jsp/head.jsp"></jsp:include>
    <jsp:include page="/WEB-INF/jsp/aside.jsp"></jsp:include>

    <!-- 内容区域 -->
    <div class="content-wrapper">

        <!-- 内容头部 -->
        <section class="content-header">
            <h1>客户管理</h1>
            <ol class="breadcrumb">
                <li>
                    <a href="index.html">
                        <i class="fa fa-dashboard"></i> 首页
                    </a>
                </li>
                <li>
                    <a href="all-order-manage-list.html">客户管理</a>
                </li>
                <li class="active">添加客户</li>
            </ol>
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">

            <!--客户信息-->
            <div class="panel panel-default">
                <div class="panel-heading">新建客户信息</div>
                <!-- onsubmit="return check()" -->
                <!-- <form id="saveForm" action="${pageContext.request.contextPath }/addCustomer.action" method="POST"> -->

                <div class="row data-type">

                    <div class="col-md-2 title">客户名称</div>
                    <div class="col-md-10 data text">
                        <input id="cust_name" type="text" name="cust_name" class="form-control" placeholder="客户名称"
                            value="">
                    </div>

                    <div class="col-md-2 title">客户来源</div>
                    <div class="col-md-10 data">
                        <select id="cust_source" name="cust_source" class="form-control" style="height:36px">
                            <option value="">请选择</option>
                            <c:forEach items="${fromType }" var="item">
                                <option value="${item.dict_id }" <c:if test="${item.dict_id == cust_source}">selected</c:if>>
                                    ${item.dict_item_name }
                                </option>
                            </c:forEach>
                        </select>
                    </div>

                    <div class="col-md-2 title">所属行业</div>
                    <div class="col-md-10 data text">
                        <select id="cust_industry" name="cust_industry" class="form-control" style="height:36px">
                            <option value="">请选择</option>
                            <c:forEach items="${industryType }" var="item">
                                <option value="${item.dict_id }" <c:if test="${item.dict_id == cust_industry}">selected</c:if>>
                                    ${item.dict_item_name }
                                </option>
                            </c:forEach>
                        </select>
                    </div>

                    <div class="col-md-2 title">客户级别</div>
                    <div class="col-md-10 data text">
                        <select id="cust_level" name="cust_level" class="form-control" style="height:36px">
                            <option value="">请选择</option>
                            <c:forEach items="${levelType }" var="item">
                                <option value="${item.dict_id }" <c:if test="${item.dict_id == cust_level}">selected</c:if>>
                                    ${item.dict_item_name }
                                </option>
                            </c:forEach>
                        </select>
                    </div>

                    <div class="col-md-2 title">联系人</div>
                    <div class="col-md-10 data line-height36">
                        <input id="cust_linkman" type="text" name="cust_linkman" class="form-control" placeholder="联系人"
                            value="">
                    </div>

                    <div class="col-md-2 title">固定电话</div>
                    <div class="col-md-10 data">
                        <input id="cust_phone" type="text" name="cust_phone" class="form-control" placeholder="固定电话"
                            value="">
                    </div>

                    <div class="col-md-2 title">移动电话</div>
                    <div class="col-md-10 data">
                        <input id="cust_mobile" type="text" name="cust_mobile" class="form-control" placeholder="移动电话"
                            value="">
                    </div>

                    <div class="col-md-2 title">邮政编码</div>
                    <div class="col-md-10 data">
                        <input id="cust_zipcode" type="text" name="cust_zipcode" class="form-control" placeholder="邮政编码"
                            value="">
                    </div>

                    <div class="col-md-2 title">联系地址</div>
                    <div class="col-md-10 data">
                        <input id="cust_address" type="text" name="cust_address" class="form-control" placeholder="联系地址"
                            value="">
                    </div>
                </div>

                <!--工具栏-->
                <div class="box-tools text-center" style="margin-bottom: 10px;">
                    <!-- <input id="saveSubmit" type="submit" class="btn bg-maroon" style="margin-right: 100px" value="保存" /> -->
                    <button id="saveSubmit" type="button" class="btn bg-maroon" onclick="saveSubmit()">保存</button>
                    <button type="button" class="btn bg-default" onclick="history.back(-1);">返回</button>
                </div>
                <!--工具栏/-->

                <!-- </form> -->
            </div>
            <!--客户信息/-->

        </section>
        <!-- 正文区域 /-->

    </div>
    <!-- 内容区域 /-->

    <script>

        // 表单提交
        function saveSubmit() {
            var cust_id = $("#cust_id").val();
            var cust_name = $("#cust_name").val();
            var cust_source = $("#cust_source").val();
            var cust_industry = $("#cust_industry").val();
            var cust_level = $("#cust_level").val();
            var cust_linkman = $("#cust_linkman").val();
            var cust_phone = $("#cust_phone").val();
            var cust_mobile = $("#cust_mobile").val();
            var cust_zipcode = $("#cust_zipcode").val();
            var cust_address = $("#cust_address").val();

            $.post(
                "${pageContext.request.contextPath }/addCustomer.action",
                {
                    "cust_id": cust_id,
                    "cust_name": cust_name,
                    "cust_source": cust_source,
                    "cust_industry": cust_industry,
                    "cust_level": cust_level,
                    "cust_linkman": cust_linkman,
                    "cust_phone": cust_phone,
                    "cust_mobile": cust_mobile,
                    "cust_zipcode": cust_zipcode,
                    "cust_address": cust_address
                },
                function (data) {
                    if (data != null) {
                        console.log("data = " + data)
                        window.location = "${pageContext.request.contextPath }/findCustomerByCust_id.action?cust_id=" + data;
                    }
                }
            );
        }
    </script>
</body>

</html>